package com.neu.cloudFactory.controller;

import com.neu.cloudFactory.VO.RentVO;
import com.neu.cloudFactory.service.RentService;
import com.neu.cloudFactory.utils.result.Result;
import com.neu.cloudFactory.utils.result.ResultFactory;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/rent")
public class RentController {

    final RentService rentService;

    public RentController(RentService rentService) {
        this.rentService = rentService;
    }

    @CrossOrigin
    @GetMapping(value = "/getRentable")
    @ResponseBody
    public Result getRentable(){
        return ResultFactory.buildSuccessResult(rentService.findAllRentable()) ;
    }

    @CrossOrigin
    @PostMapping(value = "/confirmRent")
    @ResponseBody
    public Result confirmRent(@RequestBody RentVO rentMsgVO){
        return ResultFactory.buildSuccessResult(rentService.rentEquip(rentMsgVO));
    }

}
